﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HGPFramework.LogControl
{
    public enum LogType { add, remove, edit, upp, select };

    public class HGPLogControl
    {
        string path = string.Empty;
        public string Path { get { return path; } set { path = value; } }

        public HGPLogControl() { }
        public HGPLogControl(string _path) { path = _path; }

        /// <summary>
        /// Write file Log
        /// </summary>
        /// <param name="type"></param>
        /// <param name="content"></param>
        public void WriteLine(LogType type, string content) { WriteLog(LogFormat(type, content)); }

        string LogFormat(LogType type, string content)
        {
            if (type == LogType.add)
                return (DateTime.Now.ToString() + " Them: " + content + ".");
            else if (type == LogType.edit)
                return (DateTime.Now.ToString() + " Sua: " + content + ".");
            else if (type == LogType.remove)
                return (DateTime.Now.ToString() + " Xoa: " + content + ".");
            else if (type == LogType.upp)
                return (DateTime.Now.ToString() + " Tai: " + content + ".");
            else
                return (DateTime.Now.ToString() + " LayDuLieu: " + content + ".");
        }

        void WriteLog(string data) { new FuncLog().WriteFile(path, data); }

        public string ReadLog() { return new FuncLog().ReadFile(path); }

        public void ClearLog() { new FuncLog().ClearFile(path); }
    }
}